import Cookies from 'js-cookie'

const TokenKey = 'userId'

export function getToken() {          //路由守卫变化，由路由守卫里 const user ID = getToken传进来
    return Cookies.get(TokenKey);
}

export function setToken(token){          //由account 传进来
    //登入成功保存用户信息
    let num=2   //失效为多久时间
    let time = new Date(new Date().getTime() + num * 60 * 60 * 1000);
    return Cookies.set(TokenKey, token , { expires:time})
}

export function removeToken() {
    return Cookies.remove(TokenKey)
}